package com.example.demo.Work.Producer;

import com.example.demo.RabbitMqApplication;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;

/**
 * Work模式
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = RabbitMqApplication.class)
public class Producer {

    @Resource
    private RabbitTemplate rabbitTemplate;

    /**
     * Work模型的生产者
     */
    @Test
    public void TestProviderHello() {
        for (int i = 0; i < 3; i++) {
            //    发送消息 参数：             队列名称   发送内容
            rabbitTemplate.convertAndSend("Work_RabbitMq", "Hello模型发送信息"+i);
            System.out.println("发送成功");
        }

    }

}
